DateUtil

object DateUtil

Types

Link copied to clipboard
Link copied to clipboard
data class TIKDate(val year: Int, val month: Int, val day: Int)

data structure to represent a simple year, month, day date

Properties

Link copied to clipboard

Extract the year month and day from the receiving integer based on the YYYYMMDD encoding.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val MILLIS_PER_DAY: Long = 86400000
Link copied to clipboard
Link copied to clipboard

Returns null if the Int is today's date in the YYYYMMDD form.

Link copied to clipboard
Link copied to clipboard

Return the current date encoded as an YYYYMMDD int

Link copied to clipboard
Link copied to clipboard
var today: Int
Link copied to clipboard

Does a basic sanity check to see if the Int is of the form YYYYMMDD for any reasonable date, for a very loose definition of reasonable. If it's not, this returns null.

Functions

Link copied to clipboard
fun calculateDaysBetween(beginDate: Int, endDate: Int): Int

Calculate and return the number of days in between the two dates.

Link copied to clipboard

Calculate the number of days in the current month

Link copied to clipboard

Calculate the number of days in the given year

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Function used to convert an integer date representation to a long date representation that can be used by the java.util.Date and Calendar objects, or code that interfaces with older versions of Moneydance.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Return the first date of the fiscal quarter containing 'date' if the fiscal year starts on the default fiscal year start date (month and day) specified in DateUtil.fiscalYearStartMMDD

fun firstDayInFiscalQuarter(date: Int, fiscalYearStartMMDD: Int): Int

Return the first date of the fiscal quarter containing 'date' if the fiscal year starts on the given day of the year (encoded as an integer of the form MMDD)

Link copied to clipboard

Return the first date of the fiscal year containing 'date' if the fiscal year starts on the default fiscal year start date (month and day) specified in DateUtil.fiscalYearStartMMDD

fun firstDayInFiscalYear(date: Int, fiscalYearStartMMDD: Int): Int

Return the first date of the fiscal year containing 'date' if the fiscal year starts on the given day of the year (encoded as an integer of the form MMDD)

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun getDate(year: Int, month: Int, day: Int): Int

Get the date corresponding to the given year, month and day in int date form (basically an integer YYYYMMDD).

Link copied to clipboard
fun getSecondsSinceMidnight(targetCal: Calendar = Calendar.getInstance()): Long

Get the elapsed seconds since midnight today (using the target calendar instance)

Link copied to clipboard

fun incrementDate(date: Int, numYears: Int, numMonths: Int, numDays: Int): Int

Add the given number of years, months, and days to the given date.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Return the last date of the fiscal quarter containing 'date' if the fiscal year starts on the default fiscal year start date (month and day) specified in DateUtil.fiscalYearStartMMDD

fun lastDayInFiscalQuarter(date: Int, fiscalYearStartMMDD: Int): Int

Return the last date of the fiscal quarter containing 'date' if the fiscal year starts on the given day of the year (encoded as an integer of the form MMDD)

Link copied to clipboard

Return the last date of the fiscal year containing 'date' if the fiscal year starts on the default fiscal year start date (month and day) specified in DateUtil.fiscalYearStartMMDD

fun lastDayInFiscalYear(date: Int, fiscalYearStartMMDD: Int): Int

Return the last date of the fiscal year containing 'date' if the fiscal year starts on the given day of the year (encoded as an integer of the form MMDD)

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Create a new Calendar instance and return it, initialised to the current date and with the firstDayOfWeek property set.

Link copied to clipboard
fun monthsInPeriod(start: Int, end: Int): Float

Counts the number of months between start (inclusive) and end (exclusive). Fractional months are determined in terms of the number of days in the last monthly period.

Link copied to clipboard

Set the given Calendar object to the given integer-encoded date where the decimal value of the integer is YYYYMMDD.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Return a (date) date value for the given (date) time value (same date, but with the time set to around noon)

Return a (long) date value for the given (long) time value (same date, but with the time set to around noon)

Link copied to clipboard
fun yearsInPeriod(start: Int, end: Int): Float

Counts the number of years between start (inclusive) and end (exclusive). Fractional years are determined in terms of the number of months in the last year and then by the number of days in the last month.